package de.preamp.clients.java.lib.ui;

import java.awt.datatransfer.Transferable;

import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.TransferHandler;

import de.preamp.clients.java.data.AbstractDBItem;

/**
 * @author André Stannek
 * @version 2010-07-30
 */
public class LibraryItemTransferHandler extends TransferHandler
{
    /**
     * 
     */
    private static final long serialVersionUID = 6995607870378989612L;

    @Override
    protected final Transferable createTransferable(final JComponent component)
    {
	if (component instanceof JList)
	{
	    final Object object = ((JList) component).getSelectedValue();

	    if (object instanceof AbstractDBItem)
	    {
		return ((AbstractDBItem) object);
	    }
	}
	return null;
    }

    @Override
    public final int getSourceActions(final JComponent c)
    {
	return COPY;
    }

}
